﻿using System;
using Microsoft.Office.Tools;

namespace TShooter.TfsWord.AddIn.UIManager
{
    /// <summary>
    /// Base class for all UI Containers in Outlook, Word and InfoPath.
    /// </summary>
    /// <typeparam name="TWindow">Window class in Office applications.</typeparam>
    public abstract class UIContainerBase<TWindow> 
        where TWindow : class
    {
        #region Fields

        private readonly TWindow hostWindow; // host window / inspector / explorer
        private readonly WindowCustomTaskPaneCollection<TWindow> taskPanes; // CustomTaskPane collection

        #endregion

        #region .ctor

        protected UIContainerBase(TWindow window, CustomTaskPaneCollection customTaskPanes)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            hostWindow = window;
            taskPanes = new WindowCustomTaskPaneCollection<TWindow>(this, customTaskPanes);
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets the Window object associated with the container.
        /// </summary>
        public TWindow Window
        {
            get { return hostWindow; }
        }

        /// <summary>
        /// Gets the <see cref="CustomTaskPane"/> collection.
        /// </summary>
        public WindowCustomTaskPaneCollection<TWindow> CustomTaskPanes
        {
            get { return taskPanes; }
        }

        #endregion
    }
}